<div class="layui-form">
    <div class="layui-layer-outerbox" style="margin-bottom:80px">
        <div class="layui-form-item">
            <label class="layui-form-label" style="width:100px">申请人姓名</label>
            <div class="layui-form-label layui-long-input" style="text-align:left;color:blue">
                {{$applyInfo['users']->name}}
                <input type="hidden" name="{{makeElUniqueName('apply_id')}}" value=" {{$applyInfo['id']}}" >
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width:100px">活动名称</label>
            <div class="layui-form-label layui-long-input" style="text-align:left;color:blue">
                {{$applyInfo['activities']->subject}}
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width:100px">举办单位</label>
            <div class="layui-form-label layui-long-input" style="text-align:left;color:blue">
                {{$applyInfo['majorGroup']->name}}
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width:100px">活动起始时间</label>
            <div class="layui-form-label layui-short-input" style="text-align:left;color:blue">
                {{$applyInfo['activities']->active_time_start}}
            </div>
            <label class="layui-form-label" style="width:100px">活动结束时间</label>
            <div class="layui-form-label layui-short-input" style="text-align:left;color:blue">
                {{$applyInfo['activities']->active_time_end}}
            </div>
        </div>
        {{--<div class="layui-form-item">
            <label class="layui-form-label" style="width:100px">活动类型</label>
            <div class="layui-form-label layui-long-input" style="text-align:left;color:blue">
                @foreach (\App\Activity::$ACTIVITY_TYPE_MAP as $item)
                    {{ $apply_info->activity_type==$item['key']?$item['text']:'' }}
                @endforeach
            </div>
        </div>--}}
        <div class="layui-form-item">
            <label class="layui-form-label" style="width:100px">活动参与方式</label>
            <div class="layui-form-label layui-long-input" style="text-align:left;color:blue">
                @foreach (\App\Activity::$USER_JOIN_PERMIT_TYPE_MAP as $item)
                    {{ $applyInfo['activities']->join_method==$item['key']?$item['text']:'' }}
                @endforeach
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width:100px">志愿者参与要求</label>
            <div class="layui-form-label layui-long-input" style="text-align:left;color:blue">
                {{$applyInfo['activities']->volunteer_rule}}
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width:100px">活动可获时长</label>
            <div class="layui-form-label layui-long-input" style="text-align:left;color:blue">
                {{$applyInfo['activities']->time_length}}
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width:100px">活动举办城市</label>
            <div class="layui-form-label layui-long-input" style="text-align:left;color:blue">
                {{$applyInfo['cities']->name}}
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width:100px">拒绝理由(可不填)</label>
            <div class="layui-form-label layui-long-input" style="text-align:left;color:blue">
                <textarea class="layui-textarea" id="deny_reason" name="{{makeElUniqueName('deny_reason')}}" style="display: none;">
                    把编辑器的初始内容放在这textarea即可
                </textarea>
            </div>
        </div>
    </div>
    <div class="layui-dialog-bar">
        <button class="layui-btn" lay-submit lay-filter="{{makeElUniqueName('audit_pass')}}"><i class="layui-icon">&#xe605;</i> 通过</button>&nbsp;
        <button class="layui-btn layui-btn-primary" lay-submit lay-filter="{{makeElUniqueName('audit_deny')}}"><i class="layui-icon">&#x1006;</i>  拒绝</button>
    </div>
</div>

<script>
    layui.use(['form', 'validator', 'popLayerUtil','layedit'], function(){
        var form = layui.form();
        var $ = layui.jquery;
        var layer = layui.layer;
        var popLayerUtil = layui.popLayerUtil;
        var layedit = layui.layedit;
        var denyContent = layedit.build('deny_reason'); //建立编辑器
        form.on('submit({{makeElUniqueName('audit_pass')}})', function(data){
            var index = layer.load(1);
            $.ajax({
                contentType: "application/json",
                type: 'post',
                url: '/activity/api/user_apply_audit/pass',
                data: JSON.stringify({
                    id: data.field['{{makeElUniqueName('apply_id')}}']
                }),
                success: function (outResult) {
                    layer.close(index);
                    if (outResult.Success) {
                        layer.msg(outResult.Message, { icon: 6 });
                        layer.close(popLayerUtil.index);
                        popLayerUtil.onClose();
                    } else {
                        layer.msg(outResult.Message, { icon: 5 });
                    }
                },
                error: function (error) {
                    layer.close(index);
                    layui.validator.processValidateError(error);
                }
            });
            return false;
        });
        form.on('submit({{makeElUniqueName('audit_deny')}})', function(data){
            var index = layer.load(1);
            $.ajax({
                contentType: "application/json",
                type: 'post',
                url: '/activity/api/user_apply_audit/deny',
                data: JSON.stringify({
                    id: data.field['{{makeElUniqueName('apply_id')}}'],
                    deny_reason:layedit.getContent(denyContent)
                }),
                success: function (outResult) {
                    layer.close(index);
                    if (outResult.Success) {
                        layer.msg(outResult.Message, { icon: 6 });
                        layer.close(popLayerUtil.index);
                        popLayerUtil.onClose();
                    } else {
                        layer.msg(outResult.Message, { icon: 5 });
                    }
                },
                error: function (error) {
                    layer.close(index);
                    layui.validator.processValidateError(error);
                }
            });
            return false;
        });
    });
</script>
